﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;

namespace WindowsFormsApplication
{
    static class Helper
    {
        public static byte[] Serialize<T>(T objToSerialize)
        {
            using (var mem = new MemoryStream())
            {
                ProtoBuf.Serializer.Serialize<T>(mem, objToSerialize);
                return mem.ToArray();
            }
        }

        public static T Deserialize<T>(byte[] objToSerialize)
        {
            using (var mem = new MemoryStream(objToSerialize))
            {
                return ProtoBuf.Serializer.Deserialize<T>(mem);
            }
        }
    }
}
